<%--
  Created by IntelliJ IDEA.
  User: 轩大晨
  Date: 2019/7/13
  Time: 14:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html;charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/head.jsp"%>

<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>时刻 >> 写时刻</span>
    </div>
    <div class="providerAdd">
        <form id="userForm" name="userForm" method="post"
              enctype="multipart/form-data" action="${pageContext.request.contextPath }/moment/addMomentSave.html">
            <input type="hidden" name="method" value="add">
            <!--div的class 为error是验证错误，ok是验证成功-->


            <div>
                <label >时刻类型：</label>
                <!-- 列出所有的角色分类 -->
                <%--<select name="userRole" id="userRole"></select>--%>
                <select name="category_id" id="category_id">
                    <c:if test="${categoryList != null }">
                        <option value="0">--请选择--</option>
                        <c:forEach var="category" items="${categoryList}">
                            <option <c:if test="${category.category_id == 0 }">selected="selected"</c:if>
                                    value="${category.category_id}">${category.category_name}</option>
                        </c:forEach>
                    </c:if>
                </select>
                <font color="red"></font>
            </div>
            <div class="box">
                <span class="H">有什么新鲜事想告诉大家？</span>
                <textarea name="content" id="content"></textarea>
                <label for="content" >输入要发布的内容吧！</label>
                <%--<span  id="button">发布</span>--%>
            </div>

            <div>
                <label for="a_idPicPath">添加图片:</label>
                <input type="file" id="a_idPicPath" name="a_idPicPath">
                <font color="red"></font>
            </div>
            <div class="providerAddBtn">
                <input type="submit" name="add" id="add" value="发表" >

            </div>
        </form>
    </div>
</div>
</section>
<%@include file="/WEB-INF/jsp/common/foot.jsp" %>
<%--<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/useradd.js"></script>--%>
<script type="text/javascript">
    var category_id = null;
    var content = null;
    var addBtn = null;
    var backBtn = null;
    $(function () {
        category_id = $("#category_id");
        content=$("#content");
        addBtn = $("#add");
        backBtn = $("#back");

        addBtn.click(function () {

            if(content==null||content==""){
                alert("请填写时刻内容!");
            }else if(category_id!=null&&content!=null&content!="") {
                if (confirm("是否确认提交数据")) {
                    $("#userForm").submit();
                }
            }

        });
        // content.blur(function () {
        //     if(content==null||content==""){
        //         validateTip(content.next(),{"color":"#666666"},"* 请输入时刻内容",false);
        //     }else if(content.length>255){
        //         validateTip(content.next(),{"color":"#666666"},"* 时刻内容过长",false);
        //     }
        // });
        //
        // addBtn.onclick("click",function(){
        //     if(content.attr("validateStatus") != "true"){
        //         content.blur();
        //     }
        //     else{
        //         if(confirm("是否确认提交数据")){
        //             $("#userForm").submit();
        //         }
        //     }
        // });
    });

</script>

